﻿using Css_VoteSys.Models.Database;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Css_VoteSys.Service
{
    public class UserService:IUserService
    {
        private readonly Css_VoteSysContext _db;

        public UserService(Css_VoteSysContext db)
        {
            _db = db;
        }

        /// <summary>
        /// 判断用户身份是否为管理员
        /// </summary>
        /// <param name="UserId">用户ID</param>
        /// <returns>bolen</returns>
        public bool IsRoot(int UserId) {
            var userPrivilegeId = _db.Users.FirstOrDefault(x => x.UserId == UserId).PrivilegeId;
            if(userPrivilegeId == 1) {
                return true;
            }
            return false;
        }
    }
}
